package cn.stylefeng.guns.modular.StockManConstantFactory;

import cn.stylefeng.guns.modular.item.Entity.Item;
import cn.stylefeng.guns.modular.item.mapper.ItemMapper;
import cn.stylefeng.guns.sys.core.constant.factory.IConstantFactory;
import cn.stylefeng.roses.core.util.SpringContextHolder;

public class StockManConstantFactory implements IStockManConstantFactory {
    private ItemMapper itemMapper = SpringContextHolder.getBean(ItemMapper.class);

    @Override
    public String getItemNameById(Integer itemId) {
        Item item = itemMapper.selectById(itemId);
        if(item != null){
            return item.getItemName();
        }else{
            return "--";
        }
    }

    @Override
    public String getTypeById(Integer itemId) {
        Item item = itemMapper.selectById(itemId);
        if(item != null){
            return item.getType();
        }else{
            return "--";
        }
    }

    @Override
    public String getNumberById(Integer itemId) {
        Item item = itemMapper.selectById(itemId);
        if(item != null){
            return item.getNumber().toString();
        }else{
            return "--";
        }
    }
}
